package main

import (
	"fmt"
	"time"
)

func main() {
	ch1 := make(chan int)
	ch2 := make(chan int)

	go func() {
		ch1 <- 100
	}()

	go func() {
		time.Sleep(time.Second)
		ch2 <- 200
	}()

	//当有多个协程同时进行  select会随机匹配执行一个
	//必须是协程才可以用select  case中也必须是chan类型
	select {
	case num1 := <-ch1:
		fmt.Println("num1", num1)
	case num2 := <-ch2:
		fmt.Println("num2", num2)

	}

}
